home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Developer Essentials / DTS Sample Code / Snippets / Platforms & Tools / MacApp / Windoid 1.0b2.2 / UWindoid.cp < prev    next >
Encoding:
Text File  |  1991-09-04  |  17.5 KB  |  649 lines  |  [TEXT/MPS ]

  1. // UWindoid.cp ------------------------------------------------------------------------
  2. // Copyright © 1991 by Apple Computer, Inc. All rights reserved.
  3.  
  4. #pragma once
  5.  
  6. //-------------------------------------------------------------------------------------
  7. // INCLUDES
  8.  
  9. #include "WindoidRez.h"                                        // combined header file for resource IDs
  10. #include "UWindoid.h"                                        // class definitions
  11.  
  12.  
  13. //-------------------------------------------------------------------------------------
  14. // MEMBER FUNCTIONS
  15.  
  16.  
  17. // TWINDOIDAPPLICATION ----------------------------------------------------------------
  18.  
  19. #pragma segment AInit
  20. pascal void TWindoidApplication::IWindoidApplication(OSType itsMainFileType, OSType itsCreator)
  21. {
  22.     inherited::IApplication(itsMainFileType, itsCreator);
  23.  
  24.     // So my view will be substituted when MacApp® creates the "default view"
  25.     RegisterStdType("TDefaultView", 'dflt');
  26.  
  27.     if (gDeadStripSuppression){                                // so the linker doesn't dead strip class info 
  28.         macroDontDeadStrip(TDefaultView);
  29.         macroDontDeadStrip(TFloatingMenu);
  30.         macroDontDeadStrip(TLightPalette);
  31.         macroDontDeadStrip(TWindow);
  32.     }
  33.  
  34.     // create the floating palette window
  35.     gFloatMenuWindow = (TWindow *)gViewServer->NewTemplateWindow(kLightPaletteRSRCID, NULL);
  36.     FailNIL(gFloatMenuWindow);
  37.     
  38.     // create the floating tool menu
  39.     gFloatingMenu = new TFloatingMenu;                        
  40.     gFloatingMenu->IFloatingMenu();
  41. }
  42.  
  43.  
  44. #pragma segment AInit
  45. pascal void TWindoidApplication::DoSetupMenus()
  46. {
  47.     inherited::DoSetupMenus();
  48.     Enable(cGreen,TRUE);
  49.     Enable(cYellow, TRUE);
  50.     Enable(cRed, TRUE);
  51. }
  52.  
  53.  
  54. #pragma segment AOpen
  55. pascal TDocument* TWindoidApplication::DoMakeDocument(CommandNumber /* itsCommandNumber */,
  56.                                                       TFile*    /* itsFile */)
  57. {
  58.     TWindoidDocument* aWindoidDocument = new TWindoidDocument;
  59.     aWindoidDocument->IDocument();
  60.     return aWindoidDocument;
  61. }
  62.  
  63.  
  64. // TWINDOIDDOCUMENT METHODS -----------------------------------------------------------
  65.  
  66. #pragma segment AInit
  67. pascal void TWindoidDocument::DoSetupMenus()                // setup document related menus
  68. {
  69.     inherited::DoSetupMenus();                                // default menus
  70.     Enable(cNormGreen,TRUE);                                // normal traffic light menu entries
  71.     Enable(cNormYellow,TRUE);
  72.     Enable(cNormRed,TRUE);
  73. }
  74.  
  75.  
  76. #pragma segment ASelCommand
  77. pascal void TWindoidDocument::DoMenuCommand(CommandNumber aCommandNumber)
  78. {
  79.     TCommand* cmdToPost = NULL;
  80.     
  81.     switch(aCommandNumber){
  82.         case cNormGreen:
  83.                             TGreenCommand *aGreenCommand = new TGreenCommand;
  84.                             aGreenCommand->IGreenCommand(this);
  85.                             cmdToPost = aGreenCommand;
  86.                             break;
  87.         case cNormYellow:
  88.                             TYellowCommand *aYellowCommand = new TYellowCommand;
  89.                             aYellowCommand->IYellowCommand(this);
  90.                             cmdToPost = aYellowCommand;
  91.                             break;
  92.         case cNormRed:
  93.                             TRedCommand *aRedCommand = new TRedCommand;
  94.                             aRedCommand->IRedCommand(this);
  95.                             cmdToPost = aRedCommand;
  96.                             break;
  97.         default:
  98.                             inherited::DoMenuCommand(aCommandNumber);
  99.     }
  100.     
  101.     if(cmdToPost != NULL) this->PostCommand(cmdToPost);        // post command
  102. }
  103.  
  104.  
  105. #pragma segment AOpen
  106. pascal void TWindoidDocument::DoMakeViews(Boolean /*forPrinting*/)
  107. {
  108.     TWindow*            aWindow;
  109.     TDefaultView*        aView;
  110.     FailInfo            fi;
  111.     
  112.     if(fi.Try()){                                            // start
  113.         aWindow = gViewServer->NewTemplateWindow(kDefaultWindowID, this);    
  114.                                                             // create the window
  115.  
  116.         aView   = (TDefaultView *)aWindow->FindSubView('DFLT');    // get the only view
  117.         FailNIL(aView);                                        // test
  118.         fView = aView;                                        // store in object
  119.         
  120.         fi.Success();                                        // OK
  121.     } 
  122.     else {                                                    // problems
  123.         fi.ReSignal();                                        // signal about it
  124.     }
  125. }
  126.  
  127.  
  128. #pragma segment ADoCommand
  129. pascal void TWindoidDocument::DoLight(eLights theLight)        // call view method
  130. {
  131.     if(theLight == kGreen)
  132.         fView->DrawGreen();                                    
  133.     else if(theLight == kYellow)
  134.         fView->DrawYellow();                                
  135.     else if(theLight == kRed)
  136.         fView->DrawRed();
  137. }
  138.  
  139.  
  140. // TDEFAULTVIEW METHODS -----------------------------------------------------------------------
  141.  
  142. #pragma segment AInit
  143. pascal void TDefaultView::Initialize()
  144. {
  145.     SetRect(fTrafficRect,kleft, ktop, kright, kbottom);        // initialize various fields
  146.     SetRect(fBlackTopRect, kleft, ktop, kright, ktop + 5);
  147.     SetRect(fTrafficLightFrame,kleft+1, ktop+1, kright+1, kbottom+1);
  148.  
  149.     short xvar = (kright -kleft)/5;                            // define the traffic lights 
  150.     short yvar = (kbottom -ktop)/13;                        // proportional to the view
  151.     
  152.     SetRect(fGreenRect, kleft + xvar, ktop + yvar,            // create rects
  153.                         kleft + (4 * xvar), ktop + (4 * yvar));
  154.     SetRect(fYellowRect,kleft + xvar, ktop + (5 * yvar),
  155.                         kleft + (4 * xvar), ktop + (8 * yvar));
  156.     SetRect(fRedRect,    kleft + xvar, ktop + (9 * yvar),
  157.                         kleft + (4 * xvar), ktop + (12 * yvar));
  158.     
  159.     this->fTitle = "Windoid example:";                        // title
  160.  
  161.     this->fCurrentLight = kGreen;                            // start with green
  162.     
  163.     inherited::Initialize();                                // call the real thing
  164. }
  165.  
  166.  
  167. #pragma segment Main
  168. pascal void TDefaultView::Draw(const VRect&)                  // draw our Traffic Light here
  169. {
  170.     if (GetGrafPort());
  171.  
  172.     this->DrawTrafficLight();                                // draw the object(s)
  173.     this->DrawLight();                                        // testing, temp thing
  174. }
  175.  
  176.  
  177. #pragma segment Main
  178. pascal void TDefaultView::DrawTrafficLight()                // draw the body
  179. {
  180.     PenNormal();                                                
  181.     PenSize(8, 8);
  182.     PenPat(qd.black);
  183.     FrameRect(fTrafficRect);                                // draw a dark gray frame
  184.     FrameRect(fBlackTopRect);                                // fill top
  185.  
  186.     PenSize(2,2);                                            // frame traffic lights
  187.     FrameRect(fGreenRect);
  188.     FrameRect(fYellowRect);
  189.     FrameRect(fRedRect);
  190.     
  191.     // Set font and size for subsequent display in the window
  192.     TextFont(geneva);                                        // a nice outline font
  193.     TextSize(9);
  194.     MoveTo(20, 20);
  195.     DrawString(fTitle);                                        // draw the title
  196.     PenNormal();                                            // restore the pen state
  197. }
  198.  
  199.  
  200. #pragma segment Main
  201. pascal void TDefaultView::DrawLight()                        // select light to draw
  202. {
  203.         if(this->fCurrentLight == kGreen)
  204.             this->DrawGreen();
  205.         else if (this->fCurrentLight == kYellow)
  206.             this->DrawYellow();
  207.         else if (this->fCurrentLight == kRed)
  208.             this->DrawRed();
  209. }
  210.  
  211.  
  212. #pragma segment Main
  213. pascal void TDefaultView::DrawGreen()                        // draw green light
  214. {
  215.     if( this->Focus() ){
  216.         this->fCurrentLight= kGreen;
  217.         PenNormal();
  218.         ForeColor(whiteColor);
  219.         PaintOval(fYellowRect);
  220.         PaintOval(fRedRect);
  221.     
  222.         ForeColor(greenColor);
  223.         PaintOval(fGreenRect);
  224.         PenNormal();
  225.         ForeColor(blackColor);
  226.     }
  227. }
  228.  
  229.  
  230. #pragma segment Main
  231. pascal void TDefaultView::DrawYellow()                        // draw yellow light
  232. {
  233.     if( this->Focus() ){
  234.         this->fCurrentLight= kYellow;
  235.         PenNormal();
  236.         ForeColor(whiteColor);
  237.         PaintOval(fGreenRect);
  238.         PaintOval(fRedRect);
  239.     
  240.         ForeColor(yellowColor);
  241.         PaintOval(fYellowRect);
  242.         PenNormal();
  243.         ForeColor(blackColor);
  244.     }
  245. }
  246.  
  247.  
  248. #pragma segment Main
  249. pascal void TDefaultView::DrawRed()                            // draw red light
  250. {
  251.     if( this->Focus() ){
  252.         this->fCurrentLight= kRed;
  253.         PenNormal();
  254.         ForeColor(whiteColor);
  255.         PaintOval(fYellowRect);
  256.         PaintOval(fGreenRect);
  257.     
  258.         ForeColor(redColor);
  259.         PaintOval(fRedRect);
  260.         PenNormal();
  261.         ForeColor(blackColor);
  262.     }
  263. }
  264.  
  265.  
  266.  
  267.  
  268. // TOOLSELECTCOMMAND METHODS --------------------------------------------------------------
  269.  
  270. #pragma segment ASelCommand
  271. pascal void TToolSelectCommand::IToolSelectCommand (TLightPalette* theToolsPalette,
  272.                                                      TLightPalette* theMenuToolsPalette,
  273.                                                     TLightPalette* theFloatingToolsPalette,
  274.                                                     VPoint& theMouse)
  275. {
  276.     ITearOffMenuViewTracker(cChangeTool, NULL, kCantUndo, kDoesNotCauseChange,
  277.                             NULL, theToolsPalette, NULL, theMouse);
  278.  
  279.     this->fCausesChange         = FALSE;                    // don't mark the document as changed yet
  280.     this->fTool                    = kNoTool;                    // no tool assigned yet
  281.     this->fExitTracking            = FALSE;                    // no tracking yet
  282.     this->fMenuToolsPalette     = theMenuToolsPalette;        // keep track of the menu views
  283.     this->fFloatingToolsPalette = theFloatingToolsPalette;    // as well as the Floating Window view
  284.     this->fViewConstrain        = FALSE;                    // don't constrain mouse to view limits
  285. }
  286.  
  287.  
  288. #pragma segment ADoCommand
  289. pascal void TToolSelectCommand::DoIt(void)
  290. {
  291.     // tell the TLightPalette in the menu which tool is selected
  292.     if(fMenuToolsPalette != NULL){
  293.         fMenuToolsPalette->fOldTool = fMenuToolsPalette->fCurrentTool;
  294.         fMenuToolsPalette->fCurrentTool = fTool;
  295.     }
  296.     
  297.     // tell the TLightPalette in the floating window which tool is selected
  298.     if(fFloatingToolsPalette != NULL){
  299.         fFloatingToolsPalette->fOldTool = fFloatingToolsPalette->fCurrentTool;
  300.         fFloatingToolsPalette->SelectNewTool(fTool);
  301.     }
  302.         
  303.     switch(fTool){    // Now post the Menu command which is transformed to a TCommmand inside TDocument
  304.  
  305.         case kGreen:
  306.                     gApplication->GetTarget()->HandleMenuCommand(cNormGreen);
  307.                     break;
  308.         case kYellow:
  309.                     gApplication->GetTarget()->HandleMenuCommand(cNormYellow);
  310.                     break;
  311.         case kRed:
  312.                     gApplication->GetTarget()->HandleMenuCommand(cNormRed);
  313.                     break;
  314.         case kNoTool:
  315.                     break;
  316.         default:
  317.                     break;
  318.     }
  319. }
  320.  
  321.  
  322. #pragma segment ADoCommand
  323. pascal Boolean TToolSelectCommand::IsDoneTracking(void)
  324. {
  325.     if(!StillDown() || this->fExitTracking)
  326.         return TRUE;
  327.     else
  328.         return FALSE;
  329. }
  330.  
  331.  
  332. #pragma segment ADoCommand
  333. pascal void    TToolSelectCommand::TrackFeedback  (TrackPhase         aTrackPhase,
  334.                                                 const VPoint&    anchorPoint,
  335.                                                 const VPoint&    previousPoint,
  336.                                                 const VPoint&    nextPoint,
  337.                                                 Boolean            mouseDidMove,
  338.                                                 Boolean            turnItOn)
  339. {    // give us some feedback, and react to it
  340.     if( (fView != NULL) && (fView->IsShown()) && (mouseDidMove) )
  341.         fView->TrackFeedback(aTrackPhase, anchorPoint,previousPoint, nextPoint,
  342.                                 mouseDidMove, turnItOn);
  343.  
  344.     if(turnItOn){
  345.         if(fView == (TView *)fMenuToolsPalette)                // we have a menu tool view
  346.             fTool = fMenuToolsPalette->fSelectedTool;
  347.         if(fView == (TView *)fFloatingToolsPalette)            // we have a floating tool view
  348.             fTool = fFloatingToolsPalette->fSelectedTool;
  349.     }
  350. }
  351.  
  352.  
  353. #pragma segment ASelCommand
  354. pascal TTracker* TToolSelectCommand::TrackMouse(TrackPhase         aTrackPhase,
  355.                                                 VPoint&            /*anchorPoint */,
  356.                                                 VPoint&            /*previousPoint*/,
  357.                                                 VPoint&            nextPoint,
  358.                                                 Boolean            /*mouseDidMove*/)
  359. {
  360.     if(gTrackingInMenu){
  361.         if( (fView != NULL) && (fView->IsShown()) )
  362.             this->fExitTracking = !fView->ContainsMouse(nextPoint);
  363.             
  364.         if( (aTrackPhase == trackRelease) && (fExitTracking) )
  365.             return NULL;                                    // no tracker needed
  366.     }
  367.     return this;                                            // default behaviour, return tracker
  368. }
  369.  
  370.  
  371. // TGREENCOMMAND METHODS ---------------------------------------------------------------------
  372.  
  373. #pragma segment AInit
  374. pascal void TGreenCommand::IGreenCommand(TWindoidDocument* itsDocument)
  375. {
  376.     fCommandDocument = itsDocument;                            // keep track of the document
  377.     inherited::ICommand(cNormGreen,itsDocument, FALSE, FALSE, NULL);
  378. }
  379.  
  380.  
  381. #pragma segment ADoCommand
  382. pascal void TGreenCommand::DoIt()
  383. {
  384.     fCommandDocument->DoLight(kGreen);                        // send message to document
  385.     inherited::DoIt();
  386. }
  387.  
  388.  
  389. // TYELLOWCOMMAND METHODS --------------------------------------------------------------------
  390.  
  391. #pragma segment AInit
  392. pascal void TYellowCommand::IYellowCommand(TWindoidDocument* itsDocument)
  393. {
  394.     fCommandDocument = itsDocument;                            // keep track of the document
  395.     inherited::ICommand(cNormYellow,itsDocument,FALSE, FALSE, NULL);
  396. }
  397.  
  398.  
  399. #pragma segment ADoCommand
  400. pascal void TYellowCommand::DoIt()
  401. {
  402.     fCommandDocument->DoLight(kYellow);                        // send message to document
  403.     inherited::DoIt();
  404. }
  405.  
  406.  
  407. // TREDCOMMAND METHODS -----------------------------------------------------------------------
  408.  
  409. #pragma segment AInit
  410. pascal void TRedCommand::IRedCommand(TWindoidDocument* itsDocument)
  411. {
  412.     fCommandDocument = itsDocument;                            // keep track of the document
  413.     inherited::ICommand(cNormRed,itsDocument,FALSE, FALSE,NULL);
  414. }
  415.  
  416.  
  417. #pragma segment ADoCommand
  418. pascal void TRedCommand::DoIt()
  419. {
  420.     fCommandDocument->DoLight(kRed);                        // send message to document
  421.     inherited::DoIt();
  422. }
  423.  
  424.  
  425. // TFLOATINGMENU METHODS --------------------------------------------------------------------
  426.  
  427. pascal void TFloatingMenu::IFloatingMenu() 
  428. {
  429.     TLightPalette* aLightPalette;
  430.  
  431.     ITearOffMenuView(mWindoid, kLightPaletteWidth, kLightPaletteHeight, 
  432.                         (TWindow *)gFloatMenuWindow);
  433.     
  434.     aLightPalette = new TLightPalette;
  435.     aLightPalette->ILightPalette(NULL, this);                
  436.     aLightPalette->fIdentifier = 'MTUL';
  437. }
  438.  
  439.  
  440.  
  441. // TLIGHTPALETTE METHODS --------------------------------------------------------------------
  442.  
  443. #pragma segment AInit
  444. pascal void TLightPalette::ILightPalette(TDocument* itsDocument, TView* itsSuperView)
  445. {
  446.     VPoint itsSize;
  447.     
  448.     SetVPt(itsSize, kLightPaletteWidth, kLightPaletteHeight);// inherited
  449.     IView(itsDocument, itsSuperView, gZeroVPt, itsSize, sizeFixed, sizeFixed);
  450.  
  451.     fCurrentTool  = kNoTool;                                // default settings
  452.     fOldTool      = kNoTool;                                // for all the
  453.     fSelectedTool = kNoTool;                                // tool selection fields
  454.  
  455.     this->BuildChoiceArray();                                // build Rects for use in Windoid
  456. }
  457.  
  458.  
  459.  
  460. #pragma segment Main
  461. pascal void TLightPalette::Draw(const VRect& area)            // draw palette view contents
  462. {
  463.     Rect r;
  464.     register long i;
  465.  
  466.     PenNormal();    
  467.     PenSize(1,1);
  468.     MoveTo((short)fSize.h - 1, 0);                            // make a right side drop effect
  469.     Line(0, (short)fSize.v);                        
  470.  
  471.     for(i = 0; i <= kLightsInPalette; i++){                    // frame rects
  472.         r = fChoiceArray[i];
  473.         FrameRect(r);
  474.  
  475.     }
  476.     
  477.     for(i = 0; i <= kLightsInPalette; i++){
  478.         if(i == kGreen){                                    // first rect == Green
  479.             SetRect(r,5,5,30,30);                            // define the rect
  480.             ForeColor(greenColor);                            // specify green
  481.             PaintOval(r);                                    // paint green oval
  482.             ForeColor(blackColor);                            // set back to black
  483.         }
  484.         else if(i == kYellow){                                // second rect == Yellow        
  485.             OffsetRect(r,0,33);                                // offset a little bit
  486.             ForeColor(yellowColor);                            // specify yellow
  487.             PaintOval(r);                                    // paint yellow oval    
  488.             ForeColor(blackColor);                            // set back to black
  489.         }
  490.         else if(i == kRed){                                    // third rect = Red
  491.             OffsetRect(r,0,33);                                // offset a little bit
  492.             ForeColor(redColor);                            // specify red
  493.             PaintOval(r);                                    // paint red oval
  494.             ForeColor(blackColor);                            // set back to black
  495.         }
  496.     }                                                        // end for loop
  497.         
  498.     PenNormal();
  499.     inherited::Draw(area);
  500. }
  501.  
  502.  
  503. #pragma segment AInit
  504. pascal void TLightPalette::BuildChoiceArray()                // build rect array
  505. {
  506.     short top;
  507.     register long i;
  508.     Rect r;
  509.     
  510.     top = 0;
  511.     for (i =0; i < kLightsInPalette; i++){
  512.         SetRect(r,0, top, kLightPaletteWidth - 1, top + kLightPaletteWidth - 1);
  513.         fChoiceArray[i] = r;
  514.         top = top + kLightPaletteWidth - 1;
  515.     }
  516. }
  517.  
  518.  
  519. #pragma segment ARes
  520. pascal void TLightPalette::Activate(Boolean entering)
  521. {
  522.     if(!entering)                                            // first time in this view?
  523.         fCurrentTool = kNoTool;                                // default setting
  524.     inherited::Activate(entering);                            // do the rest, TView :: Activate..
  525. }
  526.  
  527.  
  528. #pragma segment ARes
  529. pascal void TLightPalette::IRes(TDocument* itsDocument, TView* itsSuperView, 
  530.                                 TStream* itsParams)
  531. {
  532.     inherited::IRes(itsDocument, itsSuperView, itsParams);
  533.  
  534.     fCurrentTool         = kNoTool;                            // default settings
  535.     fOldTool             = kNoTool;
  536.     fSelectedTool        = kNoTool;
  537.     fCurrentTool        = kNoTool;
  538.     
  539.     this->BuildChoiceArray();                                // build Rect array
  540. }
  541.  
  542.  
  543. #pragma segment ASelCommand
  544. pascal void  TLightPalette::DoMouseCommand(VPoint& theMouse, TToolboxEvent* /*event*/,
  545.                                             Point /*hysteresis*/)
  546. {
  547.     TLightPalette*         aMenuLightPalette;
  548.     TLightPalette*        aFloatingLightPalette;
  549.     TToolSelectCommand*    aToolSelectCommand;
  550.  
  551.     aMenuLightPalette = (TLightPalette *)gFloatingMenu->FindSubView('MTUL');    
  552.     
  553.     aFloatingLightPalette = NULL;
  554.     Boolean temp = gFloatMenuWindow->IsShown();
  555.     
  556.     if( gFloatMenuWindow != NULL ){                            // exists
  557.         aFloatingLightPalette =  (TLightPalette *)gFloatMenuWindow->FindSubView('TPLT');
  558.         FailNIL(aFloatingLightPalette);
  559.     }
  560.     
  561.      aToolSelectCommand = new TToolSelectCommand;            // create a tool selection command
  562.     
  563.     aToolSelectCommand->IToolSelectCommand(this, aMenuLightPalette, 
  564.                                                 aFloatingLightPalette, theMouse);
  565.  
  566.     PostCommand(aToolSelectCommand);                        // post the tool select command    
  567. }
  568.  
  569.  
  570. #pragma segment ASelCommand
  571. pascal void TLightPalette::DoHighlightSelection(HLState /*fromHL*/, HLState toHL)
  572. {
  573.     if( (fCurrentTool != kNoTool) && (fCurrentTool < kLightsInPalette) ){     // valid selection        
  574.         if(toHL == hlOn)                                    // turn on selected tool
  575.             this->Toggle();                
  576.         
  577.         if(toHL == hlOff)                                    // turn off selected tool
  578.                 this->Toggle();                                // turn it off
  579.     }                                                         
  580. }
  581.  
  582.  
  583. #pragma segment ASelCommand
  584. pascal void TLightPalette::Toggle(void)                        // toggle between tool rects
  585. {
  586.     Rect r;
  587.     
  588.         r = fChoiceArray[fCurrentTool];                        // get the tool
  589.         UseSelectionColor();                                // hilite with the selected color
  590.         InvertRect(r);                                        // invert
  591. }
  592.  
  593.  
  594. #pragma segment ASelCommand
  595. pascal void TLightPalette::FrameTool(Rect& r)                // frame selected tool rect
  596. {
  597.     PenNormal();
  598.     PenMode(patXor);
  599.     PenSize(2,2);
  600.     FrameRect(r);
  601. }
  602.  
  603.  
  604. #pragma segment ASelCommand
  605. pascal void TLightPalette::SelectNewTool(eLights whichTool)
  606. {
  607.     Boolean foo =this->IsShown();
  608.     
  609.     if( this->IsShown() ){                                    // check if valid floating window
  610.         if( this->Focus() ){
  611.             this->DoHighlightSelection(hlOn,hlOff);            // turn current selection off
  612.             fCurrentTool = whichTool;                        // define new current tool
  613.             this->DoHighlightSelection(hlOff,hlOn);            // turn new selection on
  614.         }
  615.     }
  616. }
  617.  
  618.  
  619. #pragma segment ASelCommand
  620. pascal void TLightPalette::TrackFeedback(    TrackPhase         /*aTrackPhase*/,
  621.                                             const VPoint&    /*anchorPoint*/,
  622.                                             const VPoint&    /*previousPoint*/,
  623.                                             const VPoint&    nextPoint,
  624.                                             Boolean            mouseDidMove,
  625.                                             Boolean            turnItOn)
  626. {
  627.     Point             aPnt;
  628.     Rect             r;
  629.     register long     i;
  630.     
  631.     if(mouseDidMove){
  632.         if( this->Focus() ){
  633.             aPnt = ViewToQDPt(nextPoint);
  634.             for(i = 0; i < kLightsInPalette; i++){            // iterate
  635.                 r = fChoiceArray[i];
  636.                     if( PtInRect(aPnt,r) ){
  637.                         this->FrameTool(r);                    // frame selected tool
  638.                         if(turnItOn)
  639.                             fSelectedTool = (eLights)i;        // the tool selected
  640.                         else
  641.                             fSelectedTool =(eLights)kNoTool;// no tool selected
  642.                     }
  643.             }
  644.         }
  645.     }
  646. }
  647.  
  648.  
  649.